package com.hp.controller;

import com.hp.context.Config;
import com.hp.entity.Link;
import com.hp.result.ResultInfo;
import com.hp.result.ResultUtil;
import com.hp.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//mybatis2.x+spring4.2
@RestController
@RequestMapping("/api/link")
public class ApiLinkController {

    @Autowired
    private LinkService linkService;

    @CrossOrigin//restful
    @GetMapping("/getAllLink")
    public ResultInfo getAllLink() throws Exception{
        List<Link> list=linkService.findAll();
        ResultInfo info= ResultUtil.createSuccess(Config.MESSAGE,200,null);
        info.getSysdata().put("data",list);
        return info;
    }

}
